
var Text;
function onerror() {
	document.getElementById("InfoList").innerHTML="Wrong operation!";
	alert();
}

function onerror1() {
	document.getElementById("InfoList").innerHTML="11!";
}

function onerror2() {
	document.getElementById("InfoList").innerHTML="22!";
}

function getUserList(username) {
	var loader = new net.AjaxRequest("UserListServlet?username="+ username, dealUserList, onerror1, "GET", null);
}

function dealUserList() {
	document.getElementById("UserList").innerHTML = this.request.responseText;
}

function ta(info,username){
	if(info!=null&&info!="")
		var loader = new net.AjaxRequest("GetInfo?info="+ info+"&username="+username, dealInfo, onerror, "GET", null);
}

function dealInfo() {
	document.getElementById("Info").value =this.request.responseText;
	document.getElementById("Info").focus();
}

function getInfo(){
	var loader = new net.AjaxRequest("PostInfo", dealgetInfo, onerror2, "GET", null);
}

function dealgetInfo(){
	var text=this.request.responseText;
	if(text!=Text){
		Text=text;
		document.getElementById("InfoList").innerHTML=text;
		document.getElementById("InfoList").scrollTop=document.getElementById("InfoList").scrollHeight ;
	}	
}

document.onkeydown = function(e){
	var keynum = window.event ? e.keyCode : e.which;
	if(keynum==13)
		 document.getElementById("Info").blur();
}

function onstart(username){
	getUserList(username);
	window.setInterval("getInfo()", 200);
	window.setInterval("getUserList('')", 1000);
}
